-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preload: fix multiple regressions around global styles #7661
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides my comment, that I'm unsure about naming of the variable, this looks technically solid and fine.
👍
I tested this using the plugin (to get the js packages) and reverting the PHP changes in WordPress/gutenberg#66468 Looks good in both the site and post editors - the requests cited in WordPress/gutenberg#66468 are now prefetched by
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some missing commas, which were crashing things, but LGTM
Was this regression introduced during the 6.7 cycle? |
Yes. Not too late to update? |
@ramonjd in cycle regressions can still be fixed, so it's not too late. |
'/wp/v2/themes?context=edit&status=active', | ||
array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ), | ||
'/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on user capabilities, a different clientside request will fire, e.g.,
✅ user can update global styles: '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit',
🔕 user cannot update global styles: '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=view',
So at the moment, editors will get a clientside request since '?context=view',
isn't preloaded.
I'm wondering if it's worth changing this to "view" context based on caps.
Probably for a follow up, as this already fixes a bunch of unnecessary requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried that here just to test things out:
WordPress/gutenberg#66468 has been cherry picked to Gutenberg's wp/6.7 branch |
Do we need a second committer review to get this in the next 6.7 RC? |
@ramonjd The trunk commit can be on your approval, then re-open the trac ticket and add the |
A PR to track the backporting of WordPress/gutenberg#66468
This fixes a regression whereby requests to global styles endpoints were not being preloaded, resulting in several requests being fired clientside unnecessarily.
For performance reasons, we should preload the requests so that the data is in the store and ready to use straight away.
The outcome is that the editor loads more quickly.
Testing
Fire up this branch and head to the site editor.
Check that global-styles endpoints aren't fetched client side, but are, rather, preloaded via rest_preload_api_request
Do the same for the post editor.
Trac ticket: https://core.trac.wordpress.org/ticket/62315
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.